﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace Smile.Network.Http
{
    /// <summary>HTTP response.</summary>
    public class HttpResponse
    {
        // @Properties
        /// <summary>Gets or sets the status.</summary>
        ///
        /// <value>The status.</value>
        public HttpStatusCode Status
        {
            get
            {
                return _status;
            }
            set
            {
                _status = value;
            }
        }

        /// <summary>Gets or sets the content (bytes).</summary>
        ///
        /// <value>The content (bytes).</value>
        public byte[] ContentBytes
        {
            get
            {
                return _contentBytes;
            }
            set
            {
                _contentBytes = value;
                _content = Encoding.UTF8.GetString(_contentBytes, 0, _contentBytes.Length);
            }
        }

        /// <summary>Gets the content as a string.</summary>
        ///
        /// <value>The content.</value>
        public string Content
        {
            get
            {
                return _content;
            }
        }

        // @Public
        /// <summary>Default constructor.</summary>
        public HttpResponse()
        {
        }

        /// <summary>Constructor.</summary>
        ///
        /// <param name="status">The status.</param>
        /// <param name="bytes"> The bytes.</param>
        public HttpResponse(HttpStatusCode status, byte[] bytes)
        {
            Status = status;
            ContentBytes = bytes;
        }

        // @Private
        HttpStatusCode  _status = HttpStatusCode.NotFound;
        byte[]          _contentBytes = new byte[0];
        string          _content = string.Empty;
    }
}
